<div class="clearfix round_top grad_colour" id="nav_top">
	<?php
	$this->widget('common.widgets.PsDropDownMenu', array(
		'encodeLabel' => false,
		'items' => array(
//			array(
//				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['<img src="/themes/adminica/images/icons/small/grey/home.png" />',
//				'url' => array('/dashboard'),
//				'active' => $this->id == 'dashboard',
//			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Transactions'],
				'url' => array('/transaction'),
				'active' => $this->module->id == 'transaction',
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Contacts'],
				'url' => array('/contact'),
				'active' => $this->module->id == 'contact',
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Projects'],
				'url' => array('/projects/default'),
				'active' => $this->module->id == 'projects',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.Projects'),
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Listings'],
				'url' => 'javascript:void(0);',
				'active' => $this->module->id == 'properties',
				'items' => array(
					array(
						'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Listings.SearchListings'],
						'url' => array('/properties/search'),
					),
					array(
						'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Listings.AgencyListings'],
						'url' => array('/properties/manage'),
					),
					array(
						'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Listings.SubmittedListings'],
						'url' => array('/properties/submitted'),
						'visible' => Yii::app()->user->checkModuleAccess('Propsage.MLS.ESubmission'),
					),
				)
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Leases'],
				'url' => array('/leases'),
				'active' => $this->module->id == 'leases',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.TenancyManagement'),
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Orders'],
				'url' => array('/order/default'),
				'active' => $this->module->id == 'order',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.Order'),
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Accounting'],
				'url' => '#',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.Accounting'),
				'active' => in_array($this->id, array('invoice', 'receipt', 'commissionPayable', 'paymentVoucher')),
				'items' => array(
					array(
						'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Accounting.Invoices'],
						'url' => array('/invoice'),
						'visible' => Yii::app()->user->checkModuleAccess('Propsage.Accounting'),
					),
					array(
						'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Accounting.Receipts'],
						'url' => array('/receipt'),
						'visible' => Yii::app()->user->checkModuleAccess('Propsage.Accounting'),
					),
					array(
						'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Accounting.CommissionsPayable'],
						'url' => array('/commissionPayable'),
						'visible' => Yii::app()->user->checkModuleAccess('Propsage.Accounting.Commission'),
					),
					array(
						'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Accounting.PaymentVouchers'],
						'url' => array('/paymentVoucher'),
						'visible' => Yii::app()->user->checkModuleAccess('Propsage.Accounting.Commission'),
					),
				)
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Calendar'],
				'url' => array('/calendar'),
				'active' => $this->module->id == 'calendar',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.Calendar'),
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Marketing'],
				'active' => in_array($this->id, array('ads', 'email', 'adsControl')),
				'url' => 'javascript:void(0);',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.AdsControl'),
				'items' => array(
//					array(
//						'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Marketing.SmsMarketing'],
//						'url' => array('/ads'),
//						'active' => $this->id == 'ads',
//					),
//					array(
//						'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Marketing.EmailMarketing'],
//						'url' => array('/email'),
//						'active' => $this->id == 'email',
//						'visible' => false
//					),
					array(
						'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Marketing.AdsControl'],
						'url' => array('/adsControl'),
						'active' => $this->id == 'adsControl',
						'visible' => Yii::app()->user->checkModuleAccess('Propsage.AdsControl'),
					),
				)
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Documents'],
				'url' => array('/documents'),
				'active' => $this->module->id == 'documents',
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Reports'],
				'url' => array('/reports'),
				'active' => $this->module->id == 'reports',
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Tickets'],
				'url' => array('/tickets'),
				'active' => $this->module->id == '' && $this->id == 'tickets',
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.TicketManagement'),
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Training'],
				'url' => array('/cpd/course/courseAttendenceAccess'),
				'active' => strpos($this->id, 'cpd/') !== false,
				'visible' => Yii::app()->user->checkModuleAccess('Propsage.CPD'),
			),
			array(
				'label' => Yii::app()->user->model->agency->settings['Menu']['Prestige']['Administration'],
				'url' => array('/admin'),
				'active' => $this->module->id == 'admin' && $this->id != 'modules/adsControl',
			),
		),
		'encodeLabel' => false,
		'activeCssClass' => 'current',
		'htmlOptions' => array(
			'class' => 'float-left clearfix',
		),
		'config' => array(
			'delay' => 0,
			'animation' => array('height' => 'show'),
			'speed' => 1,
			'speedOut' => 1,
			'autoArrows' => true,
			'dropShadows' => false,
		),
		'id' => 'main_nav'
	));
	?>
    <div id="nav_top_right" class="float-right">
		<?php if (Yii::app()->user->model->agency->type == 'Franchise' && Yii::app()->user->model->agency->hasChildAgencies()): ?>
			<div id="ps_select_agency" class="float-left">
				<?php echo CHtml::form('', 'POST', array('id' => 'ps_select_agency_form')); ?>
				<img src="/themes/adminica/images/icons/small/grey/globe.png" class="ps_select_agency_icon valign-top" />
				<?php
				$this->widget('common.widgets.PsSelect2.PsSelect2', array(
					'id' => 'select_agency_id',
					'name' => 'ps_selected_agency_id',
					'value' => Yii::app()->user->getSelectedAgencyId(),
					'data' => GxHtml::listDataEx(Yii::app()->user->model->agency->getChildAgencies()),
					'htmlOptions' => array(
						'prompt' => 'All Agencies',
						'multiple' => false,
						'style' => 'width:250px;',
					)
				));
				?>
				<?php echo CHtml::endForm(); ?>
			</div>
		<?php endif; ?>
		<?php
		$this->widget('zii.widgets.CMenu', array(
			'items' => array(
				array(
					'label' => '<img src="/themes/adminica/images/icons/small/grey/mail.png" /><span class="user-private-message-bullet ' . (Yii::app()->user->model->hasUnacknowledgedPrivateMessages() ? "bullet-has-unacknowledged" : "") . '" />',
					'url' => array('/messages'),
					'active' => $this->module->id == 'messages',
					'visible' => true,
					'linkOptions' => array(
						'title' => Yii::app()->user->model->hasUnacknowledgedPrivateMessages() ? Yii::app()->user->model->countUnacknowledgedPrivateMessages() . ' message(s) need acknowledgement' : ""
					)
				),
			),
			'encodeLabel' => false,
			'activeCssClass' => 'current',
			'htmlOptions' => array(
				'class' => 'float-left clearfix',
			),
		));
		?>
    </div>
</div><!-- #nav_top -->